package me.hys.api.doctor;

import java.util.List;

import me.hys.api.BaseApi;
import me.hys.base.ApiResult;
import me.hys.base.PageQuery;
import me.hys.bo.doctor.DiagnoseBo;
import me.hys.cons.ApiStatus;
import me.hys.entity.doctor.DiagnoseEntity;
import me.hys.service.doctor.IDiagnoseManager;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Author: @author HYS . <br>
 * Date: 2015-9-26 上午1:46:23 . <br>
 * Function: 问诊接口
 */
@Controller
@RequestMapping("/api/diagnose")
public class DiagnoseApi extends BaseApi {
	@Autowired
	private IDiagnoseManager diagnoseManager;

	/**
	 * @Title : list
	 * @Description : 获取全部问诊
	 */
	@ResponseBody
	@RequestMapping(value = "/list/{start}", method = RequestMethod.GET)
	public List<DiagnoseBo> list(@PathVariable int start) {
		PageQuery<DiagnoseBo> page = getPageQuery(start);
		PageQuery<DiagnoseBo> result = diagnoseManager.findPageBo(page);
		return result.getList();
	}

	/**
	 * @Title : list
	 * @Description : 获取我的问诊
	 */
	@ResponseBody
	@RequestMapping(value = "/list/{userid}/{start}", method = RequestMethod.GET)
	public List<DiagnoseBo> mylist(@PathVariable String userid,
			@PathVariable int start) {
		PageQuery<DiagnoseBo> page = getPageQuery(start);
		page.getCondition().put("userid", userid);
		PageQuery<DiagnoseBo> result = diagnoseManager.findPageBo(page);
		return result.getList();
	}

	/**
	 * @Title : post
	 * @Description : 保存问题
	 */
	@ResponseBody
	@RequestMapping(value = "/post", method = RequestMethod.POST)
	public ApiResult post(@ModelAttribute DiagnoseEntity entity) {
		diagnoseManager.saveOrUpdate(entity);
		return new ApiResult(ApiStatus.SUCCESS, "操作成功");
	}
}
